package com.green.service.export;

import java.util.HashMap;
import java.util.Map;

public abstract class ExportDataProvider {
	protected Map<String,CellRender> renders = new HashMap<String, ExportDataProvider.CellRender>();
	public Object getElements(){
		return null;
	}
	
	public boolean existsRender(String key){
		return renders.containsKey(key);
	}
	
	public CellRender getRender(String key){
		if(existsRender(key)){
			return renders.get(key);
		}
		return new CellRender() {
			@Override
			public String getAsString(Object value) {
				if(value!=null){
					return value.toString();
				}
				return null;
			}
		};
	}
	
	public void init(){
	}
	
	public abstract class CellRender{
		public abstract String getAsString(Object value);
	}
}
